unit u_imput;


interface
 uses
  Microsoft.DirectX.DirectInput,
  Microsoft.DirectX,
  System.Windows.Forms,
  System.ComponentModel;
 type
  Input = Class
    public
      Key : Microsoft.DirectX.DirectInput.device;
      Mouse : Microsoft.DirectX.DirectInput.device;
      KeyState : KeyboardState;
      MouseState : MouseState;
      Constructor KeyandmouseCreate;
      procedure Dispose;
      procedure InitializeKeyboard(formctrl:control);
      procedure InitializeMouse(formctrl:control);
      Procedure Keybupdate;
      Procedure Mouseupdate;
  end;

implementation
 Constructor Input.KeyandmouseCreate;
  begin
    inherited Create;
    Key:= device.Create(SystemGuid.Keyboard);
    Mouse := Device.Create(SystemGuid.Mouse);
  end;

  procedure Input.InitializeKeyboard(formctrl:control);
  begin
    Key.SetCooperativeLevel(formctrl,CooperativeLevelFlags.NonExclusive or CooperativeLevelFlags.Background);
    key.SetDataFormat(DeviceDataFormat.Keyboard);
    Key.Acquire();

  end;



  Procedure Input.Keybupdate;
  begin
    KeyState := Key.GetCurrentKeyboardState;
  end;



 procedure Input.Dispose;
 begin
   key.dispose;
   mouse.dispose;
 end;

end.
